/**==================视觉组框架 V1.4 13字节==================
 * @build & maintainer hqy
 * @date of modification: 2021/05/05
 */
#include <stdio.h>
#include <cstdio>
#include <ros/ros.h>
#include "readParam.hpp"
#include "aim_cam/HPG.hpp"
#include "aim_deps/AimRos.hpp"
#include "aim_auto/AimAuto.hpp"
#include "serial_com/comm.h"
#include "aim_energy/WindMill.hpp"
#include "string"

// path to the fold
std::string path_before = "/home/nuc/pics/";

int main(int argc, char **argv)
{
    cv::Mat frame;
    ros::init(argc, argv, "main_frame");
    ros::NodeHandle nh;

    hpg::HPGrabbing grab(nh);
    grab.start();
    grab.setCameraParams(0);
    int cnt = 0;
    std::string path_after = ".png";
    do
    {
        std::string path_mid = std::to_string(cnt);
        if (grab.getMat(frame))
        {
            continue;
        }
        cv::imshow("windows", frame);
        std::string path = path_before + path_mid + path_after;
        int k = cv::waitKey(1);
        if (k == 27)
            break;
        else if (k == 's')
        {
            cnt++;
            cv::imwrite(path, frame);
        }

    } while (ros::ok());
    cv::destroyAllWindows();
    return 0;
}